package com.itbour.service.stats.impl;

import java.util.List;
import java.util.Map;

import com.itbour.com.page.JspPage;
import com.itbour.com.page.Page;
import com.itbour.dao.stats.OrderStatsDao;
import com.itbour.dto.stats.OrderStatsDto;
import com.itbour.dto.stats.YjxOrderStatsDto;
import com.itbour.dto.stats.YjxStatisUserDto;
import com.itbour.service.stats.OrderStatsService;

public class OrderStatsServiceImpl implements OrderStatsService {

	private OrderStatsDao OrderStatsDao;
	
	public Page pageOrderStats(Map<String, Object> param, Integer pageNo,
			Integer pageSize) {
		Page result = null;
		// 实际起始位置
		int skipResults = JspPage.getStartOfPage(pageNo, pageSize);
		int totalSize = OrderStatsDao.orderStatsCnt(param);
		while(totalSize >0 && totalSize <= skipResults){
			skipResults= skipResults - pageSize;
			pageNo = pageNo -1;
		}
		// 分页检索
		param.put("pageSize", pageSize);
		param.put("skipResults", skipResults);
		List<OrderStatsDto> data = OrderStatsDao.orderStatsInfo(param);
		result = new JspPage(skipResults, totalSize, pageSize, data);
		return result;
	}
	
	
	/**	获取 一键秀 订单统计
	 */
	public Page pageYjxOrderStats(Map<String, Object> param, Integer pageNo,
			Integer pageSize) {
		Page result = null;
		// 实际起始位置
		int skipResults = JspPage.getStartOfPage(pageNo, pageSize);
		int totalSize = OrderStatsDao.yjxOrderStatsCnt(param);
		while(totalSize >0 && totalSize <= skipResults){
			skipResults= skipResults - pageSize;
			pageNo = pageNo -1;
		}
		// 分页检索
		param.put("pageSize", pageSize);
		param.put("skipResults", skipResults);
		List<YjxOrderStatsDto> data = OrderStatsDao.yjxOrderStatsInfo(param);
		result = new JspPage(skipResults, totalSize, pageSize, data);
		return result;
	}
	
	
	public OrderStatsDao getOrderStatsDao() {
		return OrderStatsDao;
	}
	public void setOrderStatsDao(OrderStatsDao orderStatsDao) {
		OrderStatsDao = orderStatsDao;
	}


	/**		统计用户 一键秀
	 */
	public Page pageStatisticsUserInfo(Map<String, Object> param,  Integer pageNo,
			Integer pageSize) {
		Page result = null;
		// 实际起始位置
		int skipResults = JspPage.getStartOfPage(pageNo, pageSize);
		int totalSize = OrderStatsDao.yjxStatisticsUserCnt(param);
		while(totalSize >0 && totalSize <= skipResults){
			skipResults= skipResults - pageSize;
			pageNo = pageNo -1;
		}
		// 分页检索
		param.put("pageSize", pageSize);
		param.put("skipResults", skipResults);
		List<YjxStatisUserDto> data = OrderStatsDao.yjxStatisticsUserInfo(param);
		result = new JspPage(skipResults, totalSize, pageSize, data);
		return result;
	}

}
